<template>
  <div class="problemtrain" id="problemtrain">
    <a-tabs default-active-key="1">
      <a-tab-pane key="1" tab="FAQ库管理">
        <div class="key_one">
          <div class="search_one">
            <a-input-search
              placehh zolder="搜索问题"
              enter-button
              @search="onSearch(SearchData)"
              style="width:250px"
              v-model="SearchData"
            />
              <a-upload
                name="files"
                :multiple="true"
                :showUploadList="false"
                action="http://192.168.1.90:8080/nlpcs/nlpcsServiceSystem/importExcel"
                :headers="headers"
                @change="handleChanges"
              >
                <a-button style="margin-left: 154px;margin-bottom: 3px" > <a-icon type="upload" />导入</a-button>
              </a-upload>
<!--            <a-button icon="download" style="margin-left: 10px" @click="handleExportExcel">导出</a-button>-->
          </div>

          <div class="but">
            <a-button style="width:120px" @click="reload" icon="file-excel">新增</a-button>
          </div>

          <div class="content_question">
            <div class="question_inner1">
              <a-card title="类目" :bordered="false" class="tree">
                <div class="tree_hearder_box">
                  <div class="tree_harder">
                    <a-button class="Button_tree" @click="increase">添加类目</a-button>
                    <a-button class="Button_tree" @click="rename">编辑类目</a-button>
                    <a-button class="Button_tree" @click="remove">删除类目</a-button>
                  </div>
                </div>
                <div style="width:300px;height:530px;overflow-y:scroll;">
                  <a-tree
                    :show-line="showLine"
                    :show-icon="showIcon"
                    :tree-data="treeData"
                    @select="onSelect"
                    :replace-fields="replaceFields"
                  ></a-tree>
                </div>
              </a-card>
            </div>
            <div class="question_inner2" style="margin-top: 3px;">
              <a-table
                class="a_table"
                :data-source="listData"
                :columns="columns"
              >
                <a-tag
                  class="tagStyle"
                  slot="action"
                  slot-scope="col"
                  color="#f50"
                  v-if="col.KnowledgeStatus === 17"
                  @click="PublishKnowledge(col)"
                >失效</a-tag>
                <a-tag
                  class="tagStyle"
                  slot="action"
                  slot-scope="col"
                  color="#2db7f5"
                  v-else-if="col.KnowledgeStatus === 3"
                  @click="PublishKnowledge(col)"
                >发布</a-tag>

                <a
                  slot="action1"
                  slot-scope="col"
                  href="javascript:;"
                  @click="DescribeKnowledge(col)"
                >详情</a>
                <a slot="action2" slot-scope="col" href="javascript:;" @click="editData(col)">编辑</a>
                <a slot="action3" slot-scope="col" href="javascript:;" @click="details(col)">删除</a>
                <a
                  slot="action5"
                  slot-scope="col"
                  href="javascript:;"
                  @click="MoveKnowledgeCategory(col)"
                >转移</a>
              </a-table>
            </div>
          </div>
        </div>
      </a-tab-pane>
      <!--      <a-tab-pane key="2" tab="核心词" force-render>-->
      <!--        <div class="key_tow">-->
      <!--          <div class="search_tow">-->
      <!--            <a-input-search-->
      <!--              placeholder="搜索问题"-->
      <!--              enter-button-->
      <!--              @search="onSearch(SearchData)"-->
      <!--              style="width:250px"-->
      <!--              v-model="SearchData"-->
      <!--            />-->
      <!--            <a-button-->
      <!--              style="width:120px;margin-left:10px"-->
      <!--              @click="createWords()"-->
      <!--              icon="file-excel"-->
      <!--            >新建核心词</a-button>-->
      <!--          </div>-->

      <!--          <a-table-->
      <!--            class="a_table"-->
      <!--            :columns="columns2"-->
      <!--            :data-source="listWords"-->
      <!--            :pagination="pagination"-->
      <!--            @change="handleTableChange"-->
      <!--          >-->
      <!--            <a slot="action2" slot-scope="col" href="javascript:;" @click="editCoreWord(col)">修改</a>-->
      <!--            <a slot="action1" slot-scope="col" href="javascript:;" @click="seeData(col)">详情</a>-->
      <!--            <a slot="action3" slot-scope="col" href="javascript:;" @click="deleteCoreWord(col)">删除</a>-->
      <!--          </a-table>-->
      <!--        </div>-->
      <!--      </a-tab-pane>-->
    </a-tabs>

    <!-- 编辑类别面板 -->
    <a-modal title="编辑问题类别" :visible="rename_status" @ok="rename_ok" @cancel="rename_off">
      <a-input placeholder="重新填写名称" v-model="rename_value" />
    </a-modal>
    <!-- 添加类别面板 -->
    <a-modal title="新建问题类别" :visible="increase_stauts" @ok="increase_ok" @cancel="increase_off">
      <a-input placeholder="新建问题类别名称" v-model="increase_value" />
    </a-modal>
    <!-- 添加问题面板 -->
    <a-modal
      title="新建问题"
      width="500px"
      :visible="create_stauts"
      @ok="create_ok"
      @cancel="create_off"
    >
      <div class="Knowledge">
        <div class="Knowledge_inner Knowledge_box1">
          <p>标准问题：</p>
          <a-input style="width:400px" v-model="NlpcsTreeSon.stanQuestion"></a-input>
          <p>标准答案：</p>
          <a-input style="width:400px" v-model="NlpcsTreeSon.stanAnswer"></a-input>
          <p>选择核心词：</p>
          <a-tree-select
            v-model="values"
            style="width: 400px"
            :tree-data="treeData"
            @select="onSelect2"
            :replaceFields="replaceFields"
          />
        </div>
      </div>
      <!--      <div class="Knowledge">-->
      <!--        <div class="Knowledge_inner Knowledge_box1">-->
      <!--          <p>知识标题：</p>-->
      <!--          <a-input style="width:400px" v-model="Knowledge.KnowledgeTitle"></a-input>-->
      <!--          <p>选择核心词：</p>-->
      <!--          <a-select-->
      <!--            show-search-->
      <!--            placeholder-->
      <!--            option-filter-prop="children"-->
      <!--            style="width:400px"-->
      <!--            :filter-option="filterOption"-->
      <!--            @change="handleChange"-->
      <!--            mode="multiple"-->
      <!--          >-->
      <!--            <a-select-option-->
      <!--              width="400px"-->
      <!--              v-for="(item, i) in listWords"-->
      <!--              :value="item.CoreWordName"-->
      <!--              :key="i"-->
      <!--            >{{item.CoreWordName}}</a-select-option>-->
      <!--          </a-select>-->

      <!--          <a-collapse accordion style="width:400px;margin-top:20px">-->
      <!--            <a-collapse-panel key="1" header="相似问法">-->
      <!--              <a-input-search-->
      <!--                placeholder="输入相似问题"-->
      <!--                style="width: 350px"-->
      <!--                @search="onSearch"-->
      <!--                v-model="askData"-->
      <!--              />-->

      <!--              <div class="asking_box">-->
      <!--                <span-->
      <!--                  v-for="(item , i) in Knowledge.SimQuestions"-->
      <!--                  :key="i"-->
      <!--                  slot="i"-->
      <!--                  class="span_ask"-->
      <!--                >-->
      <!--                  {{item.Title}}-->
      <!--                  <a href="javascript:;" @click="deleteAst(i)">×</a>-->
      <!--                </span>-->
      <!--                <br />-->
      <!--              </div>-->
      <!--            </a-collapse-panel>-->

      <!-- <a-collapse-panel key="2" header="关联问题">
        <a-select
          show-search
          mode="multiple"
          placeholder="关联问题1"
          style="width:350px;margin-bottom:13px"
          @change="handleChange1"
        >
          <a-select-option
            width="400px"
            v-for="(item, i) in jsmooon"
            :value="item.KnowledgeTitle"
            :key="i"
          >{{item.KnowledgeTitle}}</a-select-option>
        </a-select>
      </a-collapse-panel>-->
      <!--          </a-collapse>-->
      <!--        </div>-->
      <!--        <div class="Knowledge_inner Knowledge_box2">-->
      <!--          答案:-->
      <!--          <br />-->
      <!--          <br />-->
      <!--          <JEditor v-model="content"></JEditor>-->
      <!--        </div>-->
      <!--      </div>-->
    </a-modal>
    <!--   编辑右侧表单面板  -->
    <a-modal
      title="新建问题"
      width="500px"
      :visible="create_edit"
      @ok="edit_ok"
      @cancel="edit_off"
    >
      <div class="Knowledge">
        <div class="Knowledge_inner Knowledge_box1">
          <p>标准问题：</p>
          <a-input style="width:400px" v-model="NlpcsTreeSon.stanQuestion"></a-input>
          <p>标准答案：</p>
          <a-input style="width:400px;" v-model="NlpcsTreeSon.stanAnswer"></a-input>
        </div>
      </div>
    </a-modal>

    <!-- 添加核心词面板 -->
    <a-modal title="新建核心词" :visible="WordName_status" @ok="WordName_ok" @cancel="WordName_off">
      <a-input placeholder="核心词名称" v-model="WordName" />
    </a-modal>

    <!-- 转移问题面板 -->
    <a-modal
      title="转移问题"
      :visible="MoveKnowledge_status"
      @ok="MoveKnowledge_ok"
      @cancel="MoveKnowledge_off"
    >
      <a-tree-select
        v-model="MoveKnowledge_value"
        style="width: 100%"
        @select="onSelect3"
        :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
        :tree-data="treeData"
        placeholder="选择转移类目"
        :replace-fields="replaceFields2"
      ></a-tree-select>
    </a-modal>

    <!-- 知识详情面板 -->
    <a-modal
      title="知识详情"
      width="1000px"
      :visible="details_status"
      @ok="details_ok"
      @cancel="details_off"
    >
      <div class="details_box">
        <div class="details_inner1">
          <a-collapse accordion style="width: 800px;margin-top:20px">
            <!--            <a-collapse-panel key="1" header="知识标题">-->
            <a-collapse-panel key="1" header="标准问题">
              <a-input disabled v-model="details_data.details_title" class="details_input"></a-input>
            </a-collapse-panel>
            <a-collapse-panel key="2" header="核心词">
              <a-input disabled v-model="details_data.details_asking" class="details_input"></a-input>
            </a-collapse-panel>
            <!--            <a-collapse-panel key="3" header="相似问法">-->
            <!--              <p v-for="(item, i) in details_data.details_similar" :key="i">{{ item.Title }}</p>-->
            <!--            </a-collapse-panel>-->
            <!--            <a-collapse-panel key="4" header="知识答案">-->
            <a-collapse-panel key="4" header="标准答案">
              <div v-html="details_content"></div>
            </a-collapse-panel>
          </a-collapse>
        </div>
      </div>
    </a-modal>

    <!-- 核心词修改面板 -->
    <a-modal title=" 核心词修改" :visible="coreWord_status" @ok="coreWord_ok" @cancel="coreWord_off">
      <a-input placeholder="重新填写名称" v-model="rename_value" />
    </a-modal>

    <!-- 核心词详情面板 -->
    <a-modal
      title=" 核心词详情"
      :visible="corecontent_status"
      @ok="corecontent_ok"
      @cancel="corecontent_off"
    ></a-modal>
  </div>
</template>

<script>
import { getAction, postAction } from '@/api/manage'
import JEditor from '@/components/jeecg/JEditor'
import {deleteAction} from "../../api/manage";

const {putAction} = require("../../api/manage");

// const columns = [
//   { title: '问题id', dataIndex: 'KnowledgeId', key: 'serviceType', width: 160 },
//   { title: '创建人', dataIndex: 'ModifyUserName', key: 'plaintiffName', width: 160 },
//   { title: '创建时间', dataIndex: 'ModifyTime', key: 'createTime', width: 160, ellipsis: true },
//   {
//     title: '标题',
//     dataIndex: 'KnowledgeTitle',
//     key: 'createTiame',
//     width: 300,
//     ellipsis: true
//   },
//   {
//     title: '状态',
//     scopedSlots: { customRender: 'action' },
//     key: 'createTiasme',
//     width: 60
//   },
//   {
//     title: '操作',
//     key: '11',
//     fixed: 'right',
//
//     ellipsis: true,
//     scopedSlots: { customRender: 'action1' }
//   },
//   {
//     title: '',
//     key: '12',
//     fixed: 'right',
//
//     scopedSlots: { customRender: 'action2' }
//   },
//   {
//     title: '',
//     key: '13',
//     fixed: 'right',
//
//     scopedSlots: { customRender: 'action3' }
//   },
//   {
//     title: '',
//     key: '16',
//     fixed: 'right',
//
//     scopedSlots: { customRender: 'action5' }
//   },
//   {
//     title: '',
//     key: '17',
//     fixed: 'right',
//
//     scopedSlots: { customRender: 'action6' }
//   }
// ]



const  columns = [
// { title: '问题id', dataIndex: 'id', key: 'id', width: 160 },
// { title: 'Path_id', dataIndex: 'pathId', key: 'pathId', width: 160 },
  { title: '序号', width:80, customRender: function (t, r, index) {
      return parseInt(index) + 1
    }},
  { title: '标准问题', dataIndex: 'stanQuestion', key: 'stanQuestion', width: 340, ellipsis: true },
  { title: '标准答案', dataIndex: 'stanAnswer', key: 'stanAnswer', width: 280, ellipsis: true },
//   {
//   title: '标题',
//     dataIndex: 'KnowledgeTitle',
//   key: 'createTiame',
//   width: 300,
//   ellipsis: true
// },
// {
//   title: '状态',
//     scopedSlots: { customRender: 'action' },
//   key: 'createTiasme',
//     width: 60
// },
  {
    title: '操作',
    key: '11',
    fixed: 'right',

    ellipsis: true,
    scopedSlots: { customRender: 'action1' }
  },
  {
    title: '',
    key: '12',
    fixed: 'right',

    scopedSlots: { customRender: 'action2' }
  },
  {
    title: '',
    key: '13',
    fixed: 'right',

    scopedSlots: { customRender: 'action3' }
  },
  {
    title: '',
    key: '16',
    fixed: 'right',

    scopedSlots: { customRender: 'action5' }
  },
  {
    title: '',
    key: '17',
    fixed: 'right',

    scopedSlots: { customRender: 'action6' }
  }
]
const columns2 = [
  { title: '核心词', dataIndex: 'CoreWordName', key: 'serviceType', width: 300 },
  { title: '同义词', dataIndex: 'qusetionType', key: 'plaintiffName', width: 450 },
  { title: '文档知识', dataIndex: 'questionTime', key: 'asdasd', width: 300 },
  { title: '问答知识', dataIndex: 'questionTime', key: 'createTime', width: 300 },
  {
    title: '操作',
    key: '11',
    fixed: 'right',
    ellipsis: true,
    scopedSlots: { customRender: 'action1' }
  },
  {
    title: '',
    key: '12',
    fixed: 'right',
    scopedSlots: { customRender: 'action2' }
  },
  {
    title: '',
    key: '13',
    fixed: 'right',
    scopedSlots: { customRender: 'action3' }
  }
]
export default {
  components: {
    JEditor
  },
  data() {
    return {
      create_edit:false,   //listData编辑弹窗变量
      queryById_pid:'',   //主附表中间变量
      values: "",   //存放中间值（编辑面板变量）

      pagination: {
        // 分页
        current: null,
        total: 0,
        showSizeChanger: true
      },
      paginations: {
        // 分页
        current: null,
        total: 0,
        showSizeChanger: true
      },
      // 新增知识数据
      content: '',
      tiveIds: '',
      NlpcsTree: {
        // ID
        id: '',
        // path_id
        pid: '',
        // 是否有子节点
        hasChild: '',
        // 类目
        category: "",
      },
      NlpcsTreeSon: {
        // ID
        id: '',
        // path_id
        pathId: '',
        // 标问
        stanQuestion: '',
        // 标答
        stanAnswer: "",
      },

      Knowledge: {
        // 标题
        KnowledgeTitle: '',
        // ID
        CategoryId: null,
        // 核心词
        CoreWords: [],
        // 关联知识
        Outlines: [],
        // 相似问题
        SimQuestions: [],
        // 答案
        solutions: [
          {
            content: '',
            PerspectiveIds: []
          }
        ]
      },
      // 转移
      MoveKnowledge_status: false,
      MoveKnowledge_value: null,
      MoveKnow_KnowledgeId: null,
      MoveKnow_KnowledgePid:'',
      MoveKnow_Question:"",
      MoveKnow_Answer:"",

      jsmooon: [],
      Asking: [],
      askData: '',
      value: undefined,
      SearchData: '',

      replaceFields: {
        children: 'childList',
        title: 'name',
        value: 'id'
      },
      replaceFields2: {
        children: 'childList',
        title: 'name',
        value: 'id'
      },
      createTree: {
        id: null
      },
      WordName: '',
      WordName_status: false,
      create_stauts: false,

      // 树状数据
      treeData: [],
      treelist: [],
      showdeser: false,
      showLine: true,
      showIcon: false,

      rename_status: false,
      rename_value: '',

      increase_stauts: false,
      increase_value: '',

      // 知识详情
      details_status: false,
      details_content: '',
      details_data: {
        details_title: '',
        details_content: '',
        details_asking: '',
        details_similar: [],
        details_relation: []
      },

      // 列表框架
      columns,
      columns2,

      // 列表数据
      listData: [],
      listWords: [],

      // 核心词修改
      coreWord_status: false,
      corecontent_status: false
    }
  },
  created() {
    this.getCategories()
    // this.getCoreWords()
  },
  methods: {
    onSelect: function (selectedKeys, info) {
      console.log(info)
      if (info.selected === true) {
        // this.createTree.id = info.selectedNodes[0].data.props.CategoryId
        // this.Knowledge.CategoryId = info.selectedNodes[0].data.props.CategoryId
        this.createTree.id = info.selectedNodes[0].data.props.id
        this.NlpcsTreeSon.pathId = info.selectedNodes[0].data.props.id
        this.NlpcsTree.pid=info.selectedNodes[0].data.props.pid
        this.NlpcsTree.hasChild=info.selectedNodes[0].data.props.hasChild
        this.NlpcsTree.category=info.selectedNodes[0].data.props.category
        // this.Knowledge.CategoryId = info.selectedNodes[0].data.props.pid
      } else {
        this.createTree.id = null
        this.NlpcsTreeSon.pathId = null
        // this.Knowledge.CategoryId = null
      }
      // this.createTree.id = info.selectedNodes[0].data.props.CategoryId
      // this.Knowledge.CategoryId = info.selectedNodes[0].data.props.CategoryId
      this.createTree.id = info.selectedNodes[0].data.props.id
      this.NlpcsTreeSon.pathId = info.selectedNodes[0].data.props.id

      /* 获取主表id对应的附表path_id数据 */
      getAction("/nlpcs/nlpcsTreeSon/queryByPid", {
        id: info.selectedNodes[0].data.props.id
      })
        .then(res => {
          console.log(res)
          this.listData = res.result
          console.log(this.listData)
        })
        .catch(err => {
          console.log(err)
        })
      // var register = {
      //   methods: 'GET',
      //   action: 'QueryKnowledges',
      //   data: {
      //     CategoryId: this.createTree.id,
      //     PageNumber: 1
      //   }
      // }
      // postAction('/customer/service/hello', register)
      //   .then(res => {
      //     console.log(typeof(res.result.TotalCount));
      //
      //     this.paginations.total = res.result.TotalCount/1
      //     this.paginations.current = 1
      //     this.listData = res.result.Knowledges
      //   })
      //   .catch(err => {
      //     console.log(err)
      //   })
    },

    onSelect2: function (value, node, extra) {
      // console.log(value),
      //   console.log(node),
      //   console.log(extra),
      console.log(value)
      this.NlpcsTreeSon.pathId = value
    },

    onSelect3:function(value, node, extra){
      this.MoveKnow_KnowledgePid=value
      console.log(this.MoveKnow_KnowledgePid)
    },

    // 获得类目
    getCategories() {
      getAction("/nlpcs/nlpcsTree/getTree", {})
        .then(res => {
          this.treeData = res.result.list;
          console.log(this.treeData)
        })
        .catch(err => {
          console.log(err)
        })
    },

    // 新增类目
    increase() {
      this.increase_stauts = true
    },
    increase_ok() {
      if (this.createTree.id != null) {
        // var register = {
        //   methods: 'GET',
        //   action: 'CreateCategory',
        //   data: {
        //     ParentCategoryId: this.createTree.id,
        //     Name: this.increase_value
        //   }
        // }
        this.increase_stauts = false
        if (this.increase_value === '') {
          this.$message.info('类目名称不能为空')
        } else {
          // postAction('/customer/service/hello', register)
          //   .then(res => {
          //     this.$message.info('添加成功')
          //     this.getCategories()
          //     this.increase_stauts = false
          //     this.increase_value = ''
          //   })
          //   .catch(err => {
          //     console.log(err)
          //   })
          postAction("/nlpcs/nlpcsTree/add", {
            id:'',
            pid:this.createTree.id,
            hasChild:'',
            category:this.increase_value
            // category:this.increase_value
          })
            .then(res => {
              console.log(res),
                this.getCategories()
            })
            .catch(err => {
              console.log(err)
            })

        }
      } else {
        this.$message.info('请选择类目')
      }
    },
    increase_off() {
      this.increase_value = ''
      this.increase_stauts = false
    },

    // 编辑类目
    rename() {
      this.rename_status = true
    },
    rename_ok() {
      if (this.createTree.id != null) {
        // var register = {
        //   methods: 'GET',
        //   action: 'UpdateCategory',
        //   data: {
        //     CategoryId: this.createTree.id,
        //     Name: this.rename_value
        //   }
        // }
        if (this.rename_value === '') {
          this.$message.info('修改名称不能为空')
        } else {
          // postAction('/customer/service/hello', register)
          //   .then(res => {
          //     this.$message.info('修改成功')
          //     this.getCategories()
          //     this.rename_status = false
          //     this.rename_value = ''
          //   })
          //   .catch(err => {
          //     console.log(err)
          //   })
          putAction("/nlpcs/nlpcsTree/edit",{
            id:this.createTree.id,
            pid:this.NlpcsTree.pid,
            category:this.rename_value
          })
            .then(res=>{
              console.log(res)
              this.getCategories()
              this.rename_status = false
            })
            .catch(err=>{
              console.log(err)
            })
        }
      } else {
        this.$message.info('修改失败，请选择类目')
      }
    },
    rename_off() {
      this.rename_value = ''
      this.rename_status = false
    },

    // 删除类目
    remove() {
      if (this.createTree.id != null) {
        // var register = {
        //   methods: 'GET',
        //   action: 'DeleteCategory',
        //   data: {
        //     CategoryId: this.createTree.id
        //   }
        // }
        // postAction('/customer/service/hello', register)
        //   .then(res => {
        //     this.$message.info('删除成功')
        //     this.getCategories()
        //   })
        //   .catch(err => {
        //     console.log(err)
        //   })
        deleteAction("/nlpcs/nlpcsTree/delete",{
          id:this.createTree.id
        })
          .then(res=>{
            console.log(res)
            this.getCategories()
          })
          .catch(err=>{
            console.log(err)
          })
      } else {
        this.$message.info('删除失败，请选择类目')
      }

    },

    // 知识详情
    DescribeKnowledge(col) {
      this.details_status = true
      // var register = {
      //   methods: 'GET',
      //   action: 'DescribeKnowledge',
      //   data: {
      //     KnowledgeId: col.KnowledgeId
      //   }
      // }
      // postAction('/customer/service/hello', register)
      //   .then(res => {
      //     console.log(res)
      //     this.details_data.details_title = res.result.KnowledgeTitle
      //     this.details_content = res.result.Solutions[0].Content
      //     this.details_data.details_asking = res.result.CoreWords[0]
      //     this.details_data.details_similar = res.result.SimQuestions
      //     this.details_status = true
      //   })
      //   .catch(err => {
      //     console.log(err)
      //   })
      getAction('/nlpcs/nlpcsTreeSon/queryById',{
        id:col.id
      })
        .then(res=>{
          this.details_data.details_title=res.result.stanQuestion
          this.details_content=res.result.stanAnswer
          this.queryById_pid = res.result.pathId
          console.log(this.queryById_pid)
          console.log(res)
          getAction("/nlpcs/nlpcsTree/queryById",{
            id:this.queryById_pid
          })
            .then(res=>{
              console.log(res)
              this.details_data.details_asking=res.result.category
            })
            .catch(err=>{
              console.log(err)
            })
        })
        .catch(err=>{
          console.log(err)
        })

    },
    details_ok() {
      this.details_status = false
    },
    details_off() {
      this.details_status = false
    },

    // 新增知识
    reload() {
      // this.Knowledge.solutions = []
      this.create_stauts = true
      this.Knowledge.solutions[0].PerspectiveIds = []
      var registers = {
        methods: 'GET',
        action: 'QueryPerspectives',
        data: {}
      }
      postAction('/customer/service/hello', registers)
        .then(res => {
          // this.Knowledge.solutions[0].PerspectiveIds.unshift(res.Perspectives[0].PerspectiveId)
          this.tiveIds = res.result.Perspectives[0].PerspectiveId
          this.content = ''
          this.Knowledge.KnowledgeTitle = ''
          this.Knowledge.CoreWords = []
          this.Knowledge.SimQuestions = []
        })
        .catch(err => {
          console.log(err)
        })
    },
    create_ok() {
      console.log(this.createTree.id)
      if (!this.NlpcsTreeSon.stanQuestion) {
        this.$message.info('标准问题不能为空！')
      }
      else if (!this.NlpcsTreeSon.stanAnswer) {
        this.$message.info('标准答案不能为空！')
      } else if(!this.NlpcsTreeSon.pathId){
        this.$message.info('pathId不能为空！')
      }else {
        postAction("/nlpcs/nlpcsTreeSon/add", {
          id: this.NlpcsTreeSon.id,
          pathId: this.NlpcsTreeSon.pathId,
          stanQuestion: this.NlpcsTreeSon.stanQuestion,
          stanAnswer: this.NlpcsTreeSon.stanAnswer
        })
          .then(res => {
            console.log(res)
          })
          .catch(err => {
            console.log(err)
          })
        this.create_off()
        // this.Knowledge.solutions[0].content = this.content
        // this.Knowledge.solutions[0].PerspectiveIds = [this.tiveIds]
      }

      //
      // if (this.Knowledge.CategoryId === null) {
      //   this.$message.info('添加失败，请选择添加的类目')
      // }
      // else if (this.Knowledge.CoreWords.length > 1) {
      //   this.$message.info('添加失败，核心词只能唯一')
      // } else if (this.Knowledge.Outlines.length > 5) {
      //   this.$message.info('添加失败，关联知识最多5条')
      // }
      //   else {
      //   this.Knowledge.solutions[0].content = this.content
      //   this.Knowledge.solutions[0].PerspectiveIds = [this.tiveIds]
      //
      //   var register = {
      //     methods: 'POST',
      //     action: 'CreateKnowledge',
      //     data: {
      //       Knowledge: JSON.stringify(this.Knowledge)
      //     }
      //   }
      //   console.log(register)
      //
      //   postAction('/customer/service/hello', register)
      //     .then(res => {
      //       console.log(res)
      //       if(res.code === 200) {
      //         this.$message.info('数据添加成功')
      //         this.create_stauts = false
      //         this.editStuta()
      //       }else{
      //         this.$message.info('当前类目存在子页，请在子页添加')
      //       }
      //     })
      //     .catch(err => {
      //       console.log(err)
      //       this.Knowledge.solutions[0].PerspectiveIds = []
      //     })
    },
    create_off() {
      this.create_stauts = false
    },

    //编辑知识
    editData(value) {
      this.create_edit = true
      this.NlpcsTreeSon.id=value.id
      this.NlpcsTreeSon.pathId=value.pathId
      this.NlpcsTreeSon.stanQuestion=value.stanQuestion
      this.NlpcsTreeSon.stanAnswer=value.stanAnswer
      this.values=value
      // var registers = {
      //   methods: 'GET',
      //   action: 'DescribeKnowledge',
      //   data: {
      //     KnowledgeId: value.KnowledgeId
      //   }
      // }
      // postAction('/customer/service/hello', registers)
      //   .then(res => {
      //     this.Knowledge.KnowledgeTitle = res.result.KnowledgeTitle
      //     this.content = res.result.Solutions[0].Content
      //     this.Knowledge.CoreWords = res.result.CoreWords
      //     this.Knowledge.SimQuestions = res.result.SimQuestions
      //     this.create_stauts = true
      //   })
      //   .catch(err => {
      //     console.log(err)
      //   })

    },
    edit_ok() {
      putAction("/nlpcs/nlpcsTreeSon/edit",{
        id:this.values.id,
        pathId:this.NlpcsTreeSon.pathId,
        stanQuestion:this.NlpcsTreeSon.stanQuestion,
        stanAnswer:this.NlpcsTreeSon.stanAnswer
      })
        .then(res=>{
          getAction('/nlpcs/nlpcsTreeSon/queryByPid',{
            id:this.values.pathId
          })
            .then(res=>{
              this.NlpcsTreeSon.stanQuestion=res.result.stanQuestion
              this.NlpcsTreeSon.stanAnswer=res.result.stanAnswer
              this.listData = res.result
              console.log(res)
            })
        })
      this.create_edit = false

    },
    edit_off() {
      this.create_edit = false
    },

    // 删除知识
    details(value) {
      console.log(value)
      deleteAction('/nlpcs/nlpcsTreeSon/delete',{
        id:value.id
      })
        .then(res=>{
          console.log(res)
          getAction("/nlpcs/nlpcsTreeSon/queryByPid", {
            id:value.pathId
          })
            .then(res => {
              console.log(res)
              this.listData = res.result
              console.log(this.listData)
            })
            .catch(err => {
              console.log(err)
            })
        })
      // var register = {
      //   methods: 'GET',
      //   action: 'DeleteKnowledge',
      //   data: {
      //     KnowledgeId: value.KnowledgeId
      //   }
      // }
      // postAction('/customer/service/hello', register)
      //   .then(res => {
      //     this.$message.info('删除成功')
      //     this.editStuta()
      //   })
      //   .catch(err => {
      //     console.log(err)
      //   })

    },

    // 修改知识状态
    PublishKnowledge(col) {
      if (col.KnowledgeStatus === 3) {
        var register = {
          methods: 'GET',
          action: 'DisableKnowledge',
          data: {
            KnowledgeId: col.KnowledgeId
          }
        }
        postAction('/customer/service/hello', register)
          .then(res => {
            this.$message.info('失效成功')
            this.editStuta()
          })
          .catch(err => {
            console.log(err)
          })
      } else {
        var register = {
          methods: 'GET',
          action: 'PublishKnowledge',
          data: {
            KnowledgeId: col.KnowledgeId
          }
        }
        postAction('/customer/service/hello', register)
          .then(res => {
            this.$message.info('发布成功')
            this.editStuta()
          })
          .catch(err => {
            console.log(err)
          })
      }
    },

    // 更新知识列表
    editStuta() {
      var register = {
        methods: 'GET',
        action: 'QueryKnowledges',
        data: {
          CategoryId: this.createTree.id
        }
      }
      postAction('/customer/service/hello', register)
        .then(res => {
          this.listData = res.result.Knowledges
        })
        .catch(err => {
          console.log(err)
        })
    },

    // 转移知识
    MoveKnowledgeCategory(col) {
      this.MoveKnowledge_status = true
      console.log(col)
      this.MoveKnow_KnowledgeId = col.id
      this.MoveKnow_Question = col.stanQuestion
      this.MoveKnow_Answer=col.stanAnswer
    },
    MoveKnowledge_ok() {
      this.MoveKnowledge_status = false
      putAction('/nlpcs/nlpcsTreeSon/edit',{
        id:this.MoveKnow_KnowledgeId,
        pathId:this.MoveKnow_KnowledgePid,
        stanQuestion:this.MoveKnow_Question,
        stanAnswer:this.MoveKnow_Answer,
      })
        .then(res=>{
          console.log(res)
          getAction("/nlpcs/nlpcsTreeSon/queryByPid", {
            id:this.MoveKnow_KnowledgeId
          })
            .then(res => {
              console.log(res)
              this.listData = res.result
              console.log(this.listData)
            })
            .catch(err => {
              console.log(err)
            })
        })
      // console.log(typeof this.MoveKnowledge_value)
      // console.log(typeof this.MoveKnow_KnowledgeId)
      // var register = {
      //   methods: 'GET',
      //   action: 'MoveKnowledgeCategory',
      //   data: {
      //     KnowledgeId: this.MoveKnow_KnowledgeId,
      //     CategoryId: this.MoveKnowledge_value
      //   }
      // }
      //
      // postAction('/customer/service/hello', register)
      //   .then(res => {
      //     this.$message.info('转移成功')
      //     this.editStuta()
      //   })
      //   .catch(err => {
      //     console.log(err)
      //   })
    },
    MoveKnowledge_off() {
      this.MoveKnowledge_status = false
    },

    // 核心词列表
    // getCoreWords() {
    //   var register = {
    //     methods: 'GET',
    //     action: 'QueryCoreWords',
    //     data: {
    //       PageNumber: 1
    //     }
    //   }
    //   postAction('/customer/service/hello', register)
    //     .then(res => {
    //       this.pagination.current = 1
    //       this.pagination.total = res.result.TotalCount/1
    //       this.listWords = res.result.CoreWords
    //     })
    //     .catch(err => {
    //       console.log(err)
    //     })
    // },

    // 创建核心词
    createWords() {
      this.WordName_status = true
    },
    WordName_ok() {
      var register = {
        methods: 'GET',
        action: 'CreateCoreWord',
        data: {
          CoreWordName: this.WordName
        }
      }
      if (this.WordName === '') {
        this.$message.info('核心词名称不能为空')
      } else {
        postAction('/customer/service/hello', register)
          .then(res => {
            this.listWords = res.result.CoreWords
            this.getCoreWords()
            this.$message.info('添加成功')
            this.WordName_status = false
            this.WordName = ''
          })
          .catch(err => {
            console.log(err)
          })
      }
    },
    WordName_off() {
      this.WordName_status = false
    },

    // 删除核心词
    deleteCoreWord(col) {
      var register = {
        methods: 'GET',
        action: 'DeleteCoreWord',
        data: {
          CoreWordName: col.CoreWordName
        }
      }
      postAction('/customer/service/hello', register)
        .then(res => {
          this.editStuta()
          this.$message.info('删除成功')
        })
        .catch(err => {
          console.log(err)
        })
    },

    // 核心词修改
    editCoreWord(col) {
      this.coreWord_status = true
      console.log(col)
    },
    coreWord_ok() {
      this.coreWord_status = false
    },
    coreWord_off() {
      this.coreWord_status = false
    },

    // 核心词详情
    seeData(col) {
      console.log(col)
      this.corecontent_status = true
    },
    corecontent_ok() {
      this.corecontent_status = false
    },
    corecontent_off() {
      this.corecontent_status = false
    },

    handleChange(value) {
      this.Knowledge.CoreWords = value
    },
    handleChange1(value) {
    },
    filterOption(input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    },
    onSearch() {
      var ar = {
        Title: this.askData
      }
      this.Knowledge.SimQuestions.push(ar)
    },
    deleteAst(item) {
      this.Knowledge.SimQuestions.splice(item, 1)
    },
    handleTableChange(item) {
      item.current
      var register = {
        methods: 'GET',
        action: 'QueryCoreWords',
        data: {
          PageNumber: item.current
        }
      }
      postAction('/customer/service/hello', register)
        .then(res => {
          this.pagination.current = item.current
          this.listWords = res.result.CoreWords
        })
        .catch(err => {
          console.log(err)
        })
    },
    onShowSizeChanges(item) {
      var register = {
        methods: 'GET',
        action: 'QueryKnowledges',
        data: {
          CategoryId: this.createTree.id,
          PageNumber: item.current
        }
      }
      postAction('/customer/service/hello', register)
        .then(res => {
          this.paginations.total = res.result.TotalCount / 1
          this.paginations.current = item.current
          this.listData = res.result.Knowledges
        })
        .catch(err => {
          console.log(err)
        })
    },
    handleChanges(info){
      this.getCategories()
      console.log("Hello")
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
        this.$message.success(`${info.file.name} 文件上传成功!`);
      } else if (info.file.status === 'error') {
        this.$message.error(`${info.file.name} 文件上传失败!`);
      }
    },
    handleExportExcel(){
      postAction("/nlpcs/nlpcsServiceSystem/exportExcel",{
      })
      .then(res=>{
        console.log(res)
      })
      .catch(err=>{
        console.log(err)
      })
    }
  },
  computed: {
    // rowSelection() {
    //   return {
    //     onChange: (selectedRowKeys, selectedRows) => {
    //       // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
    //     },
    //     onSelect: (record, selected, selectedRows) => {
    //       if (selected) {
    //         this.keyRow.push(record.key)
    //       } else {
    //         let key = record.key
    //         this.keyRow.forEach((value, item) => {
    //           if (value == key) {
    //             this.keyRow.splice(item, 1)
    //           }
    //         })
    //       }
    //     },
    //     onSelectAll: (selected, selectedRows, changeRows) => {
    //       if (this.keyRow.length == 0) {
    //         if (selected) {
    //           changeRows.forEach((value, item) => {
    //             this.keyRow.push(value.key)
    //           })
    //         } else {
    //           this.keyRow = []
    //         }
    //       } else {
    //         if (selected) {
    //           changeRows.forEach((value, item) => {
    //             this.keyRow.push(value.key)
    //           })
    //         } else {
    //           this.keyRow = []
    //         }
    //       }
    //     }
    //   }
    // }
  }
}
</script>

<style  scoped>
.ant-table > .ant-pagination {
  display: none;
}
/* .ant-pagination ant-table-pagination {
	    display: none;
	  } */
.problemtrain {
  margin: 40px;
  min-height: calc(100vh - 80px);
}
.key_one {
  position: relative;
}
.but {
  position: absolute;
  right: 0px;
  top: 0px;
}
.content_question {
  display: flex;
  justify-content: space-between;
}
.question_inner1 {
  width: 20%;
}
.question_inner2 {
  width: 75%;
}
.Button_tree {
  margin-right: 5px;
  width: 80px;
}
</style>